﻿namespace Mercury.ParticleEngine
{
    using System;
    using System.Diagnostics.Contracts;
    using System.Linq;

    /// <summary>
    /// Contains extension methods for the <see cref="T:System.String"/> class.
    /// </summary>
    public static class StringExtensions
    {
        /// <summary>
        /// Gets a value indicating whether or not the specified <see cref="T:System.String"/>
        /// value is a <c>null</c> reference, empty string or is composed solely of whitespace
        /// characters.
        /// </summary>
        /// <param name="value">The extension instance.</param>
        /// <returns><c>true</c> if <paramref name="value"/> is a <c>null</c> reference, empty
        /// string, or is composed solely of whitespace characters; else <c>false</c>.</returns>
        [Pure]
        static public Boolean IsNullOrWhitespace(this String value)
        {
            return String.IsNullOrWhiteSpace(value);

            /*
             * Use this version when compiling against .NET 3.5 or lower (eg Xbox)...
            return String.IsNullOrEmpty(value) || value.ToCharArray()
                                                       .All(Char.IsWhiteSpace);
            */
        }
    }
}